import { ChatOpenAI } from "@langchain/openai";
import { HumanMessage, SystemMessage } from "@langchain/core/messages";

const modelName = "deepseek/deepseek-chat-v3-0324:free";
const apiKey =
  "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";

const ChatOpenRouter = ({ modelName, apiKey }) => {
  return new ChatOpenAI(
    {
      modelName: modelName,
      openAIApiKey: apiKey,
      apiKey,
    },
    {
      basePath: "https://openrouter.ai/api/v1",
    }
  );
};

async function main() {
  const llm = ChatOpenRouter({ modelName, apiKey });

  const messages = [
    new SystemMessage("you are a helpful translator"),
    new HumanMessage("translate Hello to italian"),
  ];

  const result = await llm.invoke(messages);
  console.log(result.content);
}

main();
